home *** CD-ROM | disk | FTP | other *** search
/ How Many Bugs in a Box / How Many Bugs in a Box.cdr / bugs / act3 / 00340_buggyhead.ls < prev    next >
Encoding:
Text File  |  1995-03-28  |  2.9 KB  |  102 lines

  1. property bugx, bugy, bodychan, bodylist, lipchan, bugbody, buglips, bugsayit, bugsound, bugtempo, hypno, bugtext, mouseout, fluttercount
  2.  
  3. on birth me, lchan, lipset
  4.   set bugx to the locH of sprite lchan
  5.   set bugy to the locV of sprite lchan
  6.   set lipchan to lchan
  7.   puppetSprite(lchan, 1)
  8.   set buglips to lipset
  9.   set fluttercount to 1
  10.   set mouseout to 1
  11.   return me
  12. end
  13.  
  14. on sayit me
  15.   global variations, fluttercount
  16.   grabbuggy(me)
  17.   if the number of cast bugsound < 1 then
  18.     exit
  19.   end if
  20.   set soundtime to the size of cast bugsound / 183.0
  21.   puppetSound(bugsound)
  22.   set flutterinc to 64.0 / soundtime
  23.   updateStage()
  24.   set stime to the timer
  25.   repeat while the timer < (soundtime + stime + 10)
  26.     set dtime to the timer - stime
  27.     set fluttercount to fluttercount + 1
  28.     if fluttercount > 64 then
  29.       set fluttercount to 1
  30.     end if
  31.     set the locH of sprite lipchan to bugx + getAt(variations, fluttercount)
  32.     set the locV of sprite lipchan to bugy + getAt(variations, fluttercount + 16)
  33.     if dtime < (soundtime - 10) then
  34.       set the castNum of sprite lipchan to getAt(buglips, random(3) + 3)
  35.     else
  36.       set the castNum of sprite lipchan to getAt(buglips, 1)
  37.     end if
  38.     updateStage()
  39.     mydelay(5)
  40.     if the mouseDown and (mouseout = 1) then
  41.       exit repeat
  42.     end if
  43.   end repeat
  44.   set the castNum of sprite lipchan to getAt(buglips, 1)
  45.   releasebuggy(me)
  46. end
  47.  
  48. on flap me
  49.   grabbuggy(me)
  50.   repeat with ddd = 1 to 3
  51.     set the castNum of sprite lipchan to getAt(buglips, ddd)
  52.     updateStage()
  53.     mydelay(10)
  54.   end repeat
  55.   repeat with ddd = 2 down to 1
  56.     set the castNum of sprite lipchan to getAt(buglips, ddd)
  57.     updateStage()
  58.     mydelay(10)
  59.   end repeat
  60.   releasebuggy(me)
  61. end
  62.  
  63. on flapto me, xloc, yloc, dtime, vary
  64.   global variations
  65.   set dx to (xloc - bugx) / (dtime * 1.0)
  66.   set dy to (yloc - bugy) / (dtime * 1.0)
  67.   set ptime to the timer
  68.   set animcount to 1
  69.   set animinc to 0.10000000000000001
  70.   set flutterinc to 64.0 / dtime
  71.   repeat while (the timer - ptime) < dtime
  72.     set stime to the timer - ptime
  73.     set fluttercount to 1 + integer(flutterinc * stime)
  74.     set the locH of sprite lipchan to bugx + (dx * stime) + (getAt(variations, fluttercount) * vary)
  75.     set the locV of sprite lipchan to bugy + (dy * stime) + (getAt(variations, fluttercount + 16) * vary)
  76.     set animcount to animcount + animinc
  77.     if (animcount > 4) or (animcount < 1) then
  78.       set animinc to -animinc
  79.       set animcount to animcount + animinc
  80.     end if
  81.     if (the timer - ptime) < (dtime - 20) then
  82.       set the castNum of sprite lipchan to getAt(buglips, integer(animcount))
  83.     else
  84.       set the castNum of sprite lipchan to getAt(buglips, 1)
  85.     end if
  86.     updateStage()
  87.   end repeat
  88.   set bugx to the locH of sprite lipchan
  89.   set bugy to the locV of sprite lipchan
  90. end
  91.  
  92. on releasebuggy me
  93.   puppetSprite(lipchan, 0)
  94.   set hypno to 0
  95. end
  96.  
  97. on grabbuggy me
  98.   puppetSprite(lipchan, 1)
  99.   set the castNum of sprite lipchan to getAt(buglips, 1)
  100.   set hypno to 1
  101. end
  102.